// 空间坐标管理

/**
 * 设置本节点的 [x0,y0]
 * @参数 {string} x0
 * @参数 {string} y0
 */
NW02_ys.prototype.x0y0 = function (x0, y0, dw) {
    this._ngj_wz();
    if (!dw) {
        dw = 'px'
    }
    this.Jiedian.style.left = x0 + dw;
    this.Jiedian.style.top = y0 + dw;
}
//放置左上角
NW02_ys.prototype.xy_zsj = function (x, y, dw) {
    this._ngj_wz();
    this._ngj_xy_zsj(x, y, dw)
}
//放置左上角
NW02_ys.prototype.xy_zsj2 = function (x, y, dw) {
    this._ngj_wz2();
    this._ngj_xy_zsj(x, y, dw)
}
//放置左上角
NW02_ys.prototype._ngj_xy_zsj = function (x, y, dw) {
    if (!dw) {
        dw = 'px'
    }
    this.Jiedian.style.right = null;
    this.Jiedian.style.bottom = null;
    this.Jiedian.style.left = x + dw;
    this.Jiedian.style.top = y + dw;
}

//上中
NW02_ys.prototype.xy_sz = function (x, y, dw) {
    this._ngj_wz();
    this._ngj_xy_sz(nw.cj(this.Jiedian.parentNode), x, y, dw)
}
//上中
NW02_ys.prototype.xy_sz2 = function (x, y, dw) {
    this._ngj_wz2();
    this._ngj_xy_sz(nw.st, x, y, dw)
}
NW02_ys.prototype._ngj_xy_sz = function (fq, x, y, dw) {
    if (!dw) {
        dw = 'px'
    }
    this.Jiedian.style.right = null;
    this.Jiedian.style.bottom = null;

    let k = fq.ys.hqK() / 2 - this.hqK_bkw() / 2 - this.hqWBJ_z() + x;
    this.Jiedian.style.left = k + dw;
    this.Jiedian.style.top = y + dw;
}


// 放置右上角
NW02_ys.prototype.xy_ysj = function (x, y, dw) {
    this._ngj_wz();
    this._ngj_xy_ysj(x, y, dw)
}
// 放置右上角 固定定位
NW02_ys.prototype.xy_ysj2 = function (x, y, dw) {
    this._ngj_wz2();
    this._ngj_xy_ysj(x, y, dw)
}
// 放置右上角
NW02_ys.prototype._ngj_xy_ysj = function (x, y, dw) {
    if (!dw) {
        dw = 'px'
    }
    this.Jiedian.style.left = null;
    this.Jiedian.style.bottom = null;
    this.Jiedian.style.right = x + dw;
    this.Jiedian.style.top = y + dw;
}
//左中
NW02_ys.prototype.xy_zz = function (x, y, dw) {
    this._ngj_wz();
    this._ngj_xy_zz(nw.cj(this.Jiedian.parentNode), x, y, dw)
}
//左中2 固定定位
NW02_ys.prototype.xy_zz2 = function (x, y, dw) {
    this._ngj_wz2();
    this._ngj_xy_zz(nw.st, x, y, dw)
}

NW02_ys.prototype._ngj_xy_zz = function (fq, x, y, dw) {
    this.Jiedian.style.right = null;
    this.Jiedian.style.bottom = null;
    if (!dw) {
        dw = 'px'
    }
    let g = fq.ys.hqG() / 2 - this.hqG_bkw() / 2 - this.hqWBJ_s() + y;
    this.Jiedian.style.left = x + dw;
    this.Jiedian.style.top = g + dw;
}


//右中
NW02_ys.prototype.xy_yz = function (x, y, dw) {
    this._ngj_wz();
    this._ngj_xy_yz(nw.cj(this.Jiedian.parentNode), x, y, dw)
}
//右中2 固定定位
NW02_ys.prototype.xy_yz2 = function (x, y, dw) {
    this._ngj_wz2();
    this._ngj_xy_yz(nw.st, x, y, dw)
}
NW02_ys.prototype._ngj_xy_yz = function (fq, x, y, dw) {
    this.Jiedian.style.left = null;
    this.Jiedian.style.bottom = null;
    if (!dw) {
        dw = 'px'
    }
    let g = fq.ys.hqG() / 2 - this.hqG_bkw() / 2 - this.hqWBJ_s() + y;
    this.Jiedian.style.right = x + dw;
    this.Jiedian.style.top = g + dw;
}




//放置左下角
NW02_ys.prototype.xy_zxj = function (x, y, dw) {
    this._ngj_wz();
    this._ngj_xy_zxj(x, y, dw)
}
//放置左下角 固定定位
NW02_ys.prototype.xy_zxj2 = function (x, y, dw) {
    this._ngj_wz2();
    this._ngj_xy_zxj(x, y, dw)
}

//放置左下角
NW02_ys.prototype._ngj_xy_zxj = function (x, y, dw) {
    if (!dw) {
        dw = 'px'
    }
    this.Jiedian.style.right = null;
    this.Jiedian.style.top = null;
    this.Jiedian.style.left = x + dw;
    this.Jiedian.style.bottom = y + dw;
}

//下中
NW02_ys.prototype.xy_xz = function (x, y, dw) {
    this._ngj_wz();
    this._ngj_xy_xz(nw.cj(this.Jiedian.parentNode), x, y, dw)
}
//下中 固定定位
NW02_ys.prototype.xy_xz2 = function (x, y, dw) {
    this._ngj_wz2();
    this._ngj_xy_xz(nw.st, x, y, dw)
}

NW02_ys.prototype._ngj_xy_xz = function (fq, x, y, dw) {
    if (!dw) {
        dw = 'px'
    }
    this.Jiedian.style.right = null;
    this.Jiedian.style.top = null;
    let k = fq.ys.hqK() / 2 - this.hqK_bkw() / 2 - this.hqWBJ_z() + x;
    this.Jiedian.style.left = k + dw;
    this.Jiedian.style.bottom = y + dw;
}



// 放置右下角
NW02_ys.prototype.xy_yxj = function (x, y, dw) {
    this._ngj_wz();
    this._ngj_xy_yxj(x, y, dw);
}
// 放置右下角 固定定位
NW02_ys.prototype.xy_yxj2 = function (x, y, dw) {
    this._ngj_wz2();
    this._ngj_xy_yxj(x, y, dw);
}

// 放置右下角
NW02_ys.prototype._ngj_xy_yxj = function (x, y, dw) {
    if (!dw) {
        dw = 'px'
    }
    this.Jiedian.style.top = null;
    this.Jiedian.style.left = null;
    this.Jiedian.style.right = x + dw;
    this.Jiedian.style.bottom = y + dw;
}
//---------------------

//正中间
NW02_ys.prototype.xy_zzj = function (x, y, dw) {
    this._ngj_wz();
    this._ngj_xy_zzj(nw.cj(this.Jiedian.parentNode), x, y, dw)
}

//正中间 固定定位
NW02_ys.prototype.xy_zzj2 = function (x, y, dw) {
    this._ngj_wz2();
    this._ngj_xy_zzj(nw.st, x, y, dw)
}

// 放置正中间
NW02_ys.prototype._ngj_xy_zzj = function (fq, x, y, dw) {
    if (!dw) {
        dw = 'px'
    }
    this.Jiedian.style.right = null;
    this.Jiedian.style.bottom = null;
    this.Jiedian.style.top = fq.ys.hqG() / 2 - this.hqG_bkw() / 2 - this.hqWBJ_s() + y + dw;
    this.Jiedian.style.left = fq.ys.hqK() / 2 - this.hqK_bkw() / 2 - this.hqWBJ_z() + x + dw;
}



NW02_ys.prototype._ngj_wz = function () {
    if (!this.hqNYS('position')) {
        this.xgNYS({ wz: 'absolute' })
    }
}
NW02_ys.prototype._ngj_wz2 = function (gddw) {
    if (this.hqNYS('position') != 'fixed') {
        this.xgNYS({ wz: 'fixed' })
    }
}


/**
 * 【x0】
 * 
 * @param {文本} zhi  坐标值 1px
 * @param {真假} qlX1  是否清理 x1
 * @returns x0值
 */
NW02_ys.prototype.x0 = function (zhi, qlX1) {
    if (zhi) {
        if (qlX1) {
            this.Jiedian.style.right = null;
        }
        this.Jiedian.style.left = zhi;
        return this;
    }
    // return this.Jiedian.offsetLeft - this.hqWBJ_z();
    return this._ngj_zlsz(this.Jiedian.style.left);
}

/**
 * 【x1】
 * 
 * @param {文本} zhi  坐标值 1px
 * @param {真假} qlX0  是否清理 X0
 * @returns x1值
 */
NW02_ys.prototype.x1 = function (zhi, qlX0) {
    if (zhi) {
        if (qlX0) {
            this.Jiedian.style.left = null;
        }
        this.Jiedian.style.right = zhi;
        return this;
    }
    return this._ngj_zlsz(this.Jiedian.style.right);
}

/**
 * 【y0】
 * 
 * @param {文本} zhi  坐标值 1px
 * @param {真假} qlY1  是否清理 Y1
 * @returns y0值
 */
NW02_ys.prototype.y0 = function (zhi, qlY1) {
    if (zhi) {
        if (qlY1) {
            this.Jiedian.style.bottom = null;
        }
        this.Jiedian.style.top = zhi;
        return this;
    }
    // return this.Jiedian.offsetTop - this.hqWBJ_s();
    return this._ngj_zlsz(this.Jiedian.style.top)
}

/**
 * 【y1】
 * 
 * @param {文本} zhi  坐标值 1px
 * @param {真假} qlY0  是否清理 Y0
 * @returns y1值
 */
NW02_ys.prototype.y1 = function (zhi, qlY0) {
    if (zhi) {
        if (qlY0) {
            this.Jiedian.style.top = null;
        }
        this.Jiedian.style.bottom = zhi;
        return this;
    }
    return this._ngj_zlsz(this.Jiedian.style.bottom);
}

//--------------------------------------------------------------------
/**
 * 【坐标x】 包含【外边距】
 * @param {真假} jqwbj  是否减去本节点的外边距-左
 * @returns x0坐标值
 */
NW02_ys.prototype.zb_x = function (jqwbj) {
    //  this.Jiedian.offsetLeft;
    return jqwbj ? this.Jiedian.offsetLeft - this.hqWBJ_z() : this.Jiedian.offsetLeft;
}


/**
 * 取得x坐标【相对-html节点】。
 * 
 * @param {真假} jqwbj  是否减去本节点的外边距-左
 * @返回 x坐标_相对于html
 */
NW02_ys.prototype.zb_x_html = function (jqwbj) {
    let _zb = this.zb_x();
    let _FQ = this.Jiedian.offsetParent; // 父节点
    while (_FQ) {
        _zb += _FQ.offsetLeft;
        _FQ = _FQ.offsetParent;
    }
    return jqwbj ? _zb - this.hqWBJ_z() : _zb;
}

/**
 * 【坐标y】 包含【外边距】
 * @param {真假} jqwbj  是否减去本节点的外边距-上
 * @返回 Top坐标点
 */
NW02_ys.prototype.zb_y = function (jqwbj) {
    //  this.Jiedian.offsetTop;
    return jqwbj ? this.Jiedian.offsetTop - this.hqWBJ_s() : this.Jiedian.offsetTop;
}

/**
 * 取得y坐标【相对-html节点】。
 * @param {真假} jqwbj   是否减去本节点的外边距-上
 * @返回 y坐标_相对于html
 */
NW02_ys.prototype.zb_y_html = function (jqwbj) {
    let _zb = this.zb_y();
    let _FQ = this.Jiedian.offsetParent; // 父节点
    while (_FQ) {
        _zb += _FQ.offsetTop;
        _FQ = _FQ.offsetParent;
    }
    return jqwbj ? _zb - this.hqWBJ_s() : _zb;
}


// 盒子【左上角】的【坐标x】，到其盒子【右上角】的 【点】(不包含【外边距-右】)
NW02_ys.prototype.zb_xDaoYS = function () {
    return this.zb_x() + this.hqK_bkw();
}

// 盒子【左上角】的【坐标y】，到其盒子【左下角】的 【点】(不包含【外边距-右】)
NW02_ys.prototype.zb_yDaoZX = function () {
    return this.zb_y() + this.hqG_bkw();
}

/**
 * xy坐标——右连接其他节点
 * 【本节点-右上角，不要边框_右的宽度 】
 * 与
 * 【pjdx节点-左上角，不要外边距_左】
 * 连接一起（重叠）
 * 
 * @param {nw对象} pjdx 节点id或节点对象或nw对象
 * @param {真假} blXBK  是否保留本节点的【边框-右】A的空间； 是=pjdx的左边框，紧贴着A线； 否=pjdx的左边框线，覆盖A线。
 * @param {文本} dw 默认为px
 * @returns  pjdx.ys
 */
NW02_ys.prototype.xy_ylj = function (pjdx, blXBK, dw) {

    //本盒子【右上角】
    let _pjdx_x;
    let _pjdx_y;
    if (!dw) {
        dw = 'px'
    }
    //如果pjdx是本节点的儿子
    if (this.Jiedian == pjdx.Jiedian.parentNode) {
        //采用 本节点-右上角配置。
        _pjdx_y = 0
            - pjdx.ys.hqWBJ_s()//不要【_pjdx  上则-外边距】
            - this.hqBK_s(); //让本节点的【上则线】与【_pjdx  _x上则线】起点一样。
        _pjdx_x = 0
            - pjdx.ys.hqWBJ_y()//不要【_pjdx  下则-外边距】
            - pjdx.ys.hqK_bkw()//【_pjdx  顶部线】在本节点【底部线】之下
            ;
        if (blXBK) {//如果需要保留 本节点的-【边框-下】的空间
            _pjdx_x = _pjdx_x - this.hqBK_y();
        }
        pjdx.ys.xy_ysj(_pjdx_x + dw, _pjdx_y + dw);
        return pjdx.ys;
    }
    _pjdx_x = this.zb_xDaoYS() - this.hqBK_y() - pjdx.ys.hqWBJ_z();
    _pjdx_y = this.zb_y() - pjdx.ys.hqWBJ_s();
    pjdx.ys.x0y0(_pjdx_x, _pjdx_y, dw);
    return pjdx.ys;
}

//下连接。将目标的左上角坐标点，与本节点的左下角坐标点，重叠一起。
/**
 * 
 * @param {nw对象} pjdx 被接到 本节点的 左下角的 盒子
 * @param {真假} blXBK  是否保留本节点的【边框-下】A的空间； 是=pjdx的上边框，紧贴着A线； 否=pjdx的上边框线，覆盖A线。
 * @param {文本} dw  单位。默认px
 * @returns  pjdx.ys
 */
NW02_ys.prototype.xy_xlj = function (pjdx, blXBK, dw) {
    let _pjdx_x;
    let _pjdx_y;
    if (!dw) {
        dw = 'px'
    }
    //如果pjdx是本节点的儿子
    if (this.Jiedian == pjdx.Jiedian.parentNode) {
        //采用 本节点-左下角配置。
        _pjdx_x = 0
            - pjdx.ys.hqWBJ_z()//不要【_pjdx  左则-外边距】
            - this.hqBK_z(); //让本节点的【左则线】与【_pjdx  _x左则线】起点一样。
        _pjdx_y = 0
            - pjdx.ys.hqWBJ_x()//不要【_pjdx  下则-外边距】
            - pjdx.ys.hqG_bkw()//【_pjdx  顶部线】在本节点【底部线】之下
            // - this.hqBK_x()    //【底部线】重合
            ;
        if (blXBK) {//如果需要保留 本节点的-【边框-下】的空间
            _pjdx_y = _pjdx_y - this.hqBK_x();
        }

        pjdx.ys.xy_zxj(_pjdx_x + dw, _pjdx_y + dw);
        return pjdx.ys;
    }
    //本盒子【右上角】
    // x  边框一样。不包括 外边距-左。）
    _pjdx_x = this.zb_x() - pjdx.ys.hqWBJ_z();
    _pjdx_y = this.zb_yDaoZX() - pjdx.ys.hqWBJ_s();
    if (!blXBK) {//如果不需要保留 本节点的-【边框-下】的空间
        _pjdx_y = _pjdx_y - this.hqBK_x();
    }
    pjdx.ys.x0y0(_pjdx_x, _pjdx_y, dw);
    return pjdx.ys;
}